Skip to content

fix(network): don't show a saved SSID when Wi-Fi is disconnected on macOS#397

Open
ykworx wants to merge 1 commit into
dracula:masterfrom
ykworx:fix/network-stale-saved-ssid
Open

fix(network): don't show a saved SSID when Wi-Fi is disconnected on macOS#397
ykworx wants to merge 1 commit into
dracula:masterfrom
ykworx:fix/network-stale-saved-ssid

Conversation

@ykworx

@ykworx ykworx commented Jun 28, 2026

Copy link
Copy Markdown

Problem

On macOS, scripts/network.sh derives the candidate Wi-Fi name (wifi_network) from:

networksetup -listpreferredwirelessnetworks "$ifname" | awk 'NR==2 && sub("\t","") { print; exit }'

listpreferredwirelessnetworks lists saved / preferred networks, not the current association. It is used as the fallback when getairportnetwork reports "You are not associated with an AirPort network."

So when Wi-Fi is off but the machine is online via Ethernet, the host ping passes, getairportnetwork correctly returns "not associated", and the module falls back to the first saved network — showing a stale SSID (e.g. an old phone hotspot) the machine is not connected to.

Closes #396.

Fix

Gate the Darwin Wi-Fi branch on the interface actually being associated, before consulting any SSID source:

if [[ "$(ifconfig "$ifname" 2>/dev/null | awk '/status:/ {print $2}')" != "active" ]]; then
  echo "$ethernet_label"
  return
fi

ifconfig "$ifname" reports status: active only when the interface is associated to an AP (inactive when Wi-Fi is off or unassociated). This signal stays readable even though the SSID itself is gated behind Location Services on macOS 15+.

The existing #370 SSID resolution (getairportnetwork + the listpreferredwirelessnetworks/ipconfig fallback) is left untouched, so there is no behavior change for users currently on Wi-Fi — only the not-associated case stops surfacing a saved name.

Testing

macOS 26.3, Wi-Fi off + online via Ethernet:

  • Before: module shows the first saved network (e.g. an old hotspot name).
  • After: module shows Ethernet.

bash -n scripts/network.sh passes.

…acOS

`scripts/network.sh` derives `wifi_network` from
`networksetup -listpreferredwirelessnetworks`, which lists saved/preferred
networks rather than the current association. When Wi-Fi is off but the host
is online via Ethernet, `getairportnetwork` reports "not associated" and the
module falls back to the first saved network, displaying a stale SSID
(e.g. an old phone hotspot) the machine is not connected to.

Gate the Wi-Fi branch on the interface actually being associated
(`ifconfig "$ifname"` -> `status: active`) before consulting any SSID source.
A not-associated interface now reports the Ethernet/Offline label. The dracula#370
connected-Wi-Fi SSID resolution is left untouched, so there is no regression
for users currently on Wi-Fi.

Fixes dracula#396

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@ethancedwards8 ethancedwards8 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read this before contributing: https://github.com/dracula/tmux/blob/master/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Bug: network module shows a saved/preferred SSID (stale Wi-Fi name) when Wi-Fi is off on macOS

2 participants